# 创建库
add_library(MathFunctions mysqrt.cxx)

target_link_libraries(MathFunctions tutorial_compiler_flags)

# 将包含目录添加到目标
target_include_directories(MathFunctions
			INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
			)
			
# 可执行文件和配置的头文件
set(installbale_libs MathFunctions tutorial_compiler_flags)
install(TARGETS ${installable_libs} DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)

include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
	#include <cmath>
	int main() {
		std::log(1.0);
		return 0;
	}
" HAVE_LOG)
check_cxx_source_compiles("
	#include <cmath>
	int main() {
		std::exp(1.0);
		return 0;
	}
" HAVE_EXP)

if (HAVE_LOG AND HAVE_EXP)
	target_compile_definitions(MathFunctions
							   PRIVATE "HAVE_LOG" "HAVE_EXP")
endif()